from django.urls import path, re_path

from .views.loginLogView import LoginInfoView
from .views.themeView import ThemeView
from .views.userInfo import getUserInfo
from .views.permissionsView import getMenuByRoleView, RoleView, MenuView, getParentMenuView, \
    getMenuTree, MenuByRoleView, setRoleByUserView, getRoleByUserView, getRouteByUser, DelRole
from rest_framework.routers import SimpleRouter
from Apps.System.views.corpView import CorpView
from Apps.System.views.corpUserView import CorpUserView

route = SimpleRouter()
# 企业
route.register("corp", CorpView, basename="corp")
# 企业用户
route.register("corpuser", CorpUserView, basename="corpuser")
# 角色
route.register("role", RoleView, basename="role")
# 菜单
route.register("menu", MenuView, basename="menu")
# 获取用户信息
route.register("userInfo", getUserInfo, basename="info")
# 登陆信息
route.register("loginInfo", LoginInfoView, basename="info")

urlpatterns = [

                  # 获单时使用取上级级菜单，新建菜单时
                  path('getParentMenu/', getParentMenuView.as_view()),
                  # 获取菜单树，绑定角色菜单时使用（编辑角色，获取所有菜单）
                  path('getMenuTree/', getMenuTree.as_view()),
                  # 获取对应角色的菜单(编辑角色时，获取该角色的菜单）
                  path('getMenuByRole/', getMenuByRoleView.as_view()),

                  # 设置角色和用户关系，增加和修改，查询
                  path('RoleByUser/', setRoleByUserView.as_view()),
                  # 查询用户的分配角色
                  path('getRoleByUser/', getRoleByUserView.as_view()),
                  # 删除角色
                  path('DelRole/', DelRole.as_view()),

                  # 查询对应用户的路由
                  path('getRouteByUser/', getRouteByUser.as_view()),

                  # 设置和获取主题
                  path('getTheme/', ThemeView.as_view({"get": "list", "post": "create"})),
                  # 设置菜单和角色关系，增加和修改，查询
                  path('MenuByRole/', MenuByRoleView.as_view()),
                  # 登陆日志
                  path('loginInfo/', LoginInfoView.as_view({"get": 'list'})),

              ] + route.urls
